<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
	<title>Cropping Plan</title>


<SCRIPT LANGUAGE="JavaScript">

function setCropFromJavascript(id){
    document.jsap.setCropFromJavascript(id);
}

function setCropFromJava(id){
    alert(id);
}

function savePlan(){
}

</SCRIPT>

	
</head>

<body>
<?php 
include_once 'plan_func.php';
include_once 'functions.php';
$allBlocks = getAllBlocks();


/*categoryname;categoryid!...*/

$categoryNameString = null;
$allCategories = getAllCategories();

for($i = 0; $i<count($allCategories); $i++){
	$categoryNameString = $categoryNameString.$allCategories[$i]['categoryname'].';'.$allCategories[$i]['categoryid'].'!';
}

//echo $categoryNameString;

/*cropname;cropid;catid!...*/

$cropNameString = null;
$allCrops = getAllCrops();
for($i = 0; $i<count($allCrops); $i++){
	$cropNameString = $cropNameString.$allCrops[$i]['cropname'].';'.$allCrops[$i]['cropid'].';'.$allCrops[$i]['categoryid'].'!';
}

$firstCrop = $allCrops[0]['cropid'];

//echo $cropNameString;

/*the string for plan, current year*/
/*
$planString = null;
$planYear = '2010';
$planBlockId = 1;
$planString = getPlan($planBlockId, $planYear);
*/
//echo $planString;


?>

	<div id="logo">
		<h1><a href="#">Dilmun Tools  </a></h1>
		<p><em> A CS5150 Project</a></em></p>
	</div>
	<hr />
	<!-- end #logo -->
	<div id="header">
		<div id="menu">
			<ul>
				<li><a href="cropDatabaseInfo.php" class="first">Crop Explorer</a></li>
				<li class="current_page_item"><a href="insertData.php">Add Crop Data</a></li>
				<li><a href="croppingPlan.php">Cropping Plan</a></li>
			</ul>
		</div>
		<!-- end #menu -->
	</div>
	<!-- end #header -->
	<!-- end #header-wrapper -->
	<div id="page">
		<div id="content">
            <div class="post">
		  		<!-- Start of content-->
				<h2 class="title"><a href="#">Cropping Plan</a></h2>
				<p class="meta"></p>


                <p>
                <?php foreach($allBlocks as $i => $j): ?>
                    <INPUT TYPE=RADIO NAME="bloks" id="<?php echo $i ?>"><?php echo $j ?></INPUT><BR />
                <?php endforeach; ?>
                </p>
                
    
                <br />		
                <INPUT TYPE=SUBMIT VALUE="View">
						
                <br/><br/><br/>
				
                <select name="cropselector" id="cropselector" onchange="setCropFromJavascript(this.value)">
                <?php foreach($allCrops as $c): ?>
                    <?php if($c['cropid'] == $firstCrop): ?>
                        <option selected="selected" value="<?php echo $c['cropid']?>">
                    <?php else: ?>
                        <option value="<?php echo $c['cropid']?>">
                    <?php endif; ?>
                        <?php echo $c['cropname'] ?>
                        </option>
                <?php endforeach; ?>
                </select>
                
                <div id="tableDisplay">
                
                
                    <object type="application/x-java-applet;version=1.4.1"
                    width= "900" height= "500"  name="jsap" id="jsap">
                        <param name="code" value="croppingplanap.CroppingPlanAp">
                        <param name="mayscript" value="yes">
                        <param name="scriptable" value="true">
                        <?php
                        
                        echo "<param name=\"first_crop\" value=\"$firstCrop\">";
                        echo "<param name=\"all_categories\" value=\"$categoryNameString\">";
                        echo "<param name=\"all_crops\" value=\"$cropNameString\">";
                        //echo "<param name=\"map_to_load\" value=\"$planString\">";
                
                        echo "<param name=\"map_to_load\" value=\"$flats\">";
                        ?>
                        <param name="name" value="jsapplet">
                    </object>

                
                <!--
                <applet name="croppingplanap" id="croppingplanap" code="croppingplanap.CroppingPlanAp.class" width="900" height="500">
                <?php
        /*
                echo "<param name=\"first_crop\" value=\"$firstCrop\">";
                echo "<param name=\"all_categories\" value=\"$categoryNameString\">";
                echo "<param name=\"all_crops\" value=\"$cropNameString\">";
                //echo "<param name=\"map_to_load\" value=\"$planString\">";
        
                echo "<param name=\"map_to_load\" value=\"$flats\">";*/
                ?>
                Error: Your browser does not support the <code>applet</code> tag.
                </applet>-->
                </div>
            </div><!--col1-->
        </div>
	</div><!-- end #content -->
	
	<div style="clear: both;">&nbsp;</div>
    <!-- end #page -->
    <div id="footer">
        <p>Copyright (c) 2010 Dilmun Hill Team.</p>
    </div>
    <!-- end #footer -->

</body>
</html>